<?php echo $this->fetch('header.html'); ?>
<script type="text/javascript" src="<?php echo $this->res_base . "/" . 'js/jquery.vtip.js'; ?>" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
    $('#add_time_from').datepicker({dateFormat: 'yy-mm-dd',changeMonth: true, changeYear: true});
    $('#add_time_to').datepicker({dateFormat: 'yy-mm-dd',changeMonth: true, changeYear: true});
	$('.checkitem').attr('checked', false);//用于删除时返回复选框全部取消
});
</script>
<style type="text/css">
.width_nowrap {width:140px;height:18px;line-height:18px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
.tatr_cancel td,.tatr_cancel td .bhong,.tatr_cancel td a{color:#999}
.tatr_cancel td img{filter:alpha(opacity=40);opacity:0.4;}
</style>
<div id="rightTop">
  <ul class="subnav">
    <li><a class="btn0" href="index.php?app=kd_order">运单列表</a></li>
    <li><a class="btn1" href="index.php?app=kd_order&act=add">添加运单</a></li>
    <li><a class="btn1" href="index.php?app=kd_order&act=import">批量导入</a></li>
  </ul>
</div>
<div class="mrightTop">
    <div class="fontl">
<form method="get">
    <input type="hidden" name="app" value="kd_order" />
    状态：<select name="status">
	<option value="-1">=请选择=</option>
	<option value="0" <?php if ($_GET['status'] == '0'): ?>selected="selected"<?php endif; ?>>未入库</option>
    <option value="1" <?php if ($_GET['status'] == '1'): ?>selected="selected"<?php endif; ?>>部分入库</option>
	<option value="2" <?php if ($_GET['status'] == '2'): ?>selected="selected"<?php endif; ?>>已入库</option>
    <option value="3" <?php if ($_GET['status'] == '3'): ?>selected="selected"<?php endif; ?>>待付款</option>
    <option value="5" <?php if ($_GET['status'] == '5'): ?>selected="selected"<?php endif; ?>>已付款</option> 
    <option value="6" <?php if ($_GET['status'] == '6'): ?>selected="selected"<?php endif; ?>>待发货</option>
    <option value="7" <?php if ($_GET['status'] == '7'): ?>selected="selected"<?php endif; ?>>已发货</option>  
    <option value="8" <?php if ($_GET['status'] == '8'): ?>selected="selected"<?php endif; ?>>已完成</option>
    <option value="9" <?php if ($_GET['status'] == '9'): ?>selected="selected"<?php endif; ?>>已取消</option>  
	</select>&nbsp;
    <input class="queryInput" type="text" name="key" value="<?php echo htmlspecialchars($_GET['key']); ?>" style="width:280px" placeholder="运单号/快递单号/转运单号/收货件人/手机/会员名"/>&nbsp;
    <input class="queryInput" type="text" name="no" value="<?php echo htmlspecialchars($_GET['no']); ?>" style="width:190px" placeholder="入仓号/麻袋号/包裹号/报关单号"/>&nbsp;
    添加时间：<input type="text" value="<?php echo $_GET['add_time_from']; ?>" id="add_time_from" name="add_time_from" class="pick_date" /> 至
    <input type="text" value="<?php echo $_GET['add_time_to']; ?>" id="add_time_to" name="add_time_to" class="pick_date" />
    <select name="pagenum">
      <option value="20" <?php if ($this->_var['pagenum'] == 20): ?>selected<?php endif; ?>>每页20条</option>
      <option value="50" <?php if ($this->_var['pagenum'] == 50): ?>selected<?php endif; ?>>每页50条</option>
      <option value="100" <?php if ($this->_var['pagenum'] == 100): ?>selected<?php endif; ?>>每页100条</option>
      <option value="150" <?php if ($this->_var['pagenum'] == 150): ?>selected<?php endif; ?>>每页150条</option>
      <option value="200" <?php if ($this->_var['pagenum'] == 200): ?>selected<?php endif; ?>>每页200条</option>
   </select>
    <input type="submit" class="formbtn" value="查询" />
</form>
    </div>
    <div class="fontr"><?php echo $this->fetch('page.top.html'); ?></div>
</div>

<form action="" method="post" id="form_post" target="_blank">
<div class="tdare">
<table width="100%" cellspacing="0" class="dataTable">
    <tr class="tatr1">
      <td width="20" class="firstCell"><input type="checkbox" class="checkall" /></td>
        <td><span ectype="order_by" fieldname="order_alias.order_id">编号</span></td>
        <td><span ectype="order_by" fieldname="yundanhao">运单号</span></td>
        <td>物流</td>
        <td><span ectype="order_by" fieldname="status">运单状态</span></td>
        <td>寄件人</td>
        <td>收件人</td>
        <td>收件人手机</td>
        <td><span ectype="order_by" fieldname="SumGoodsAmount">物品数量</span></td>
        <td><span ectype="order_by" fieldname="SumGoodsWorth">物品价值</span></td>
        <td>合计费用</td>
        <td>快递公司单号</td>
        <td>入仓号-包裹货号</td>
        <td>添加时间</td>
        <td>操作</td>
    </tr>
    <?php $_from = $this->_var['orders']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'order');if (count($_from)):
    foreach ($_from AS $this->_var['order']):
?>
    <tr class="tatr2 <?php if ($this->_var['order']['status'] == '9'): ?>tatr_cancel<?php endif; ?>">
      <td class="firstCell"><input type="checkbox" class="checkitem" value="<?php echo $this->_var['order']['order_id']; ?>" /></td>
      <td class="left_style" ><a href="index.php?app=kd_order&act=view&order_id=<?php echo $this->_var['order']['order_id']; ?>" class="vtip" title="点击查看运单详情"><?php echo $this->_var['order']['order_id']; ?></a></td>
        <td><?php if ($this->_var['order']['yundanhao']): ?><a href="<?php echo $this->_var['site_url']; ?>/index.php?app=kd_order&ydh=<?php echo $this->_var['order']['yundanhao']; ?>" target="_blank" class="vtip" title="查询【<?php echo $this->_var['order']['yundanhao']; ?>】的物流"><?php echo $this->_var['order']['yundanhao']; ?></a><?php endif; ?></td>
        <td><a href='javascript: dialog("添加物流","iframe:index.php?app=kd_wuliu&act=add&order_id=<?php echo $this->_var['order']['order_id']; ?>&iframe=1","850","500","");' class="vtip" title="添加物流"><img src="templates/style/images/act_add.gif" width="12" height="13" /></a>
        <a href='javascript: dialog("查看物流","iframe:index.php?app=kd_wuliu&act=order&order_id=<?php echo $this->_var['order']['order_id']; ?>","850","500","");' class="vtip" title="查看物流"><img src="templates/style/images/act_search.gif" width="14" height="13" /></a>
        </td>
        <td><?php if ($this->_var['order']['status'] == '0'): ?><font color="#f00">未入库</font>
        <?php elseif ($this->_var['order']['status'] == '1'): ?><font color="#FF9900">部分入库</font>
        <?php elseif ($this->_var['order']['status'] == '2'): ?><font color="#009966">已入库</font>
        <?php elseif ($this->_var['order']['status'] == '3'): ?><font color="#00f">待付款</font>
        <?php elseif ($this->_var['order']['status'] == '5'): ?><font color="#FF00FF">已付款</font>
        <?php elseif ($this->_var['order']['status'] == '6'): ?><font color="#00f">待发货</font>
        <?php elseif ($this->_var['order']['status'] == '7'): ?><font color="#336600">已发货</font>
        <?php elseif ($this->_var['order']['status'] == '8'): ?>已完成
        <?php elseif ($this->_var['order']['status'] == '9'): ?><font color="#999">已取消</font>
        <?php endif; ?></td>        
        <td><?php echo $this->_var['order']['txt_name']; ?></td>
        <td><?php echo $this->_var['order']['txtRece_name']; ?></td>
        <td><?php echo $this->_var['order']['txtRece_mobilephone']; ?></td>
        <td><strong class="bhong"><?php echo $this->_var['order']['SumGoodsAmount']; ?></strong> 件</td>
        <td><strong class="bhong"><?php echo price_format($this->_var['order']['SumGoodsWorth']); ?></strong></td>
        <td><?php if ($this->_var['order']['totalfei']): ?><strong class="bhong"><?php echo price_format($this->_var['order']['totalfei']); ?></strong><?php endif; ?></td>
        <td><?php if ($this->_var['order']['express'] && $this->_var['order']['expressNo']): ?><a href="http://www.baidu.com/s?wd=<?php echo $this->_var['order']['express']; ?><?php echo $this->_var['order']['expressNo']; ?>&ie=UTF-8" target="_blank" class="vtip" title="用百度查询【<?php echo $this->_var['order']['express']; ?><?php echo $this->_var['order']['expressNo']; ?>】物流"><?php echo $this->_var['order']['express']; ?><?php echo $this->_var['order']['expressNo']; ?></a><?php endif; ?></td>
        <td><?php echo $this->_var['order']['zhudanNo']; ?><?php if ($this->_var['order']['baoguoNo']): ?>-<?php echo $this->_var['order']['baoguoNo']; ?><?php endif; ?></td>
        <td><?php echo local_date("Y-m-d H:i",$this->_var['order']['addtime']); ?></td>
        <td><a href="index.php?app=kd_order&act=feiyong&order_id=<?php echo $this->_var['order']['order_id']; ?>" title="运单费用计算" class="vtip">费用</a>
        <a href="index.php?app=kd_order&act=edit&lcj=yundan&order_id=<?php echo $this->_var['order']['order_id']; ?>">修改</a></td>
  </tr>
  <?php endforeach; else: ?>
</table>
<table width="100%" cellspacing="0" class="dataTable">
  <tr bgcolor="#FFFFFF">
    <td style="padding:8px; color:#F00; text-align:center; font-size:14px;">没有符合条件的记录</td>
  </tr>
  <?php endif; unset($_from); ?><?php $this->pop_vars();; ?>
</table>
<div>
<?php if ($this->_var['orders']): ?>
<div id="dataFuncs">
  <div id="batchAction" class="left paddingT15">
   &nbsp;&nbsp;&nbsp;<label><input type="checkbox" class="checkall" /> 全选</label>&nbsp;&nbsp;
  <input class="formbtn1 batchButton" type="button" value="添加物流" onclick="piliang_wuliu()"/> 
  <input class="formbtn batchButton" type="button" value="删除" name="id" uri="index.php?app=kd_order&act=drop" presubmit="confirm('确定要删除选择的记录吗？删除后不可恢复，请谨慎操作');" /> 
  </div>
  <div class="pageLinks"><?php echo $this->fetch('page.bottom.html'); ?></div>
<?php endif; ?>

 </div>
  <div class="clear"></div>
</div>
</div>
</form>
<script type="text/javascript">
function piliang_wuliu(){
	var items = '';/* 获取选中的项 */
	$('.checkitem:checked').each(function(){items += this.value + ',';});
	items = items.substr(0, (items.length - 1));
	if(items==""){alert('请选择要添加物流的运单');return;}
	dialog("批量添加快递物流","url:get?index.php?app=kd_order&act=piliang_wuliu&order_id="+items,"700","auto",""); 
}
//function piliang_status(){
//	var items = '';/* 获取选中的项 */
//	$('.checkitem:checked').each(function(){items += this.value + ',';});
//	items = items.substr(0, (items.length - 1));
//	if(items==""){alert('请选择要添加物流的运单');return;}
//	dialog("批量修改运单状态","url:get?index.php?app=kd_order&act=piliang_status&order_id="+items,"700","auto",""); 
//}
</script>
<?php echo $this->fetch('footer.html'); ?>